
package com.joysuch.wwyt.bp.enums;

public enum DepartType {

    //GROUP_CORP(0, "集团公司"), COMPANY(1, "公司"), FACTORY(2, "工厂"), DEPART(3, "部门");
    COMPANY(1, "公司级"),  DEPART(3, "部门级"), WORKSHOP(4, "车间级"), TEAM(5, "班组级");
    private int id;
    private String name;

    private DepartType(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static DepartType findByName(String name) {
        DepartType[] values = DepartType.values();
        for (DepartType v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static DepartType findById(Integer level) {
        DepartType[] values = DepartType.values();
        for (DepartType v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer level) {
        DepartType[] values = DepartType.values();
        for (DepartType v : values) {
            if (v.getId() == level) {
                return v.getName();
            }
        }
        return null;
    }
}
